#include "arch.h"
#include "native.h"
#include "util/Pool.h"

#if CFG_NATIVE_PROCESS_FS_INTERCEPT
UINT32 SegInterceptBaseFS=0;
UINT32 SegInterceptSizeFS=0;
UINT32 SegInterceptBottomFS=0;
UINT32 SegInterceptLimitFS=0;
#endif
#if CFG_NATIVE_PROCESS_GS_INTERCEPT
UINT32 SegInterceptBaseGS=0;
UINT32 SegInterceptSizeGS=0;
UINT32 SegInterceptBottomGS=0;
UINT32 SegInterceptLimitGS=0;
#endif

UINT32 originalSP;
UINT32 originalBP;

void arch_initSimulation () {
  X86NATIVE_GET_REG_EBP(originalBP);
  X86NATIVE_GET_REG_ESP(originalSP);
#if CFG_NATIVE_PROCESS_FS_INTERCEPT
  SegInterceptSizeFS = CFG_NATIVE_PROCESS_FS_INTERCEPT;
  SegInterceptBottomFS = (UINT32)CALLOC(1, SegInterceptSizeFS);
  SegInterceptBaseFS = SegInterceptBottomFS + (SegInterceptSizeFS / 2);
  SegInterceptLimitFS = (SegInterceptSizeFS/2) - 1;
#endif
#if CFG_NATIVE_PROCESS_GS_INTERCEPT
  SegInterceptSizeGS = CFG_NATIVE_PROCESS_GS_INTERCEPT;
  SegInterceptBottomGS = (UINT32)CALLOC(1, SegInterceptSizeGS);
  SegInterceptBaseGS = SegInterceptBottomGS + (SegInterceptSizeGS / 2);
  SegInterceptLimitGS = (SegInterceptSizeGS/2) - 1;
#endif
}
